I am changing my development structure to have rewrite urls for fuse/action
and I thought it's cool if I represent all URLs like google (http://www.google.co.in/search?hl=en&client=firefox-a)
so http://mysite.com?index.php?action=search&q=vikrant should look like http://mysite.com/search?q=vikrant
for this purpose I have first tried a simple rule to match anything after "/".
RewriteEngine On
RewriteRule ^(.*)$ index.php?action=$1 [L]
but when I print GET variables then it s only giving me the part before "?" (that was strange)
Then after googling a bit I just got the hint that Mod Rewrite do not matches string after "?"
because it's treating it as %{QUERYSTRING}, hence I have created following rule to achieve the result which is running perfect for me
RewriteEngine On
RewriteRule ^/?([^/][^\./]*)[:;,\.]*$ index.php?action=$1&%{QUERY_STRING} [L]
10 comments:
Works brilliantly. Thank you
I have got the following URL witch isnt workin either:
RewriteRule ^(.*)/photos/\?level=(.*)&id=(.*)$ photos.php?lang=$1&level=$2&id=$3 [L]
RewriteRule ^(.*)/photos/\?level=(.*)$ photos.php?lang=$1&level=$2 [L]
RewriteRule ^(.*)/photos/$ photos.php?lang=$1 [L]
http://www.alsacorp.eu/fr/photos/?level=collection&id=2
I thought i had to escape ? with \ ? but the page still doesnt work, ccan you help me out with how i should do it?
Cheers mate,
I had spent half on this before I found this page.
Thank you!
Ah, thanks. This was making me crazy :-)
Query strings are not part of a URL.
You must use
RewriteCond %{QUERY_STRING} ^level=(.*)&id=(.*)$
RewriteRule ^(.*)/photos/$ photos.php?lang=$1&level=%1&id=%2 [L]
I had a full week searching for something like this
THANK YOU!!!
I had a full week googling about this...
THANK YOU!!
Cheer. That's help a lot!
Thank you
you genius - just saved me a lot of time!
Post a Comment